/**
 * @file skoll.tools.baloon.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.tools.baloon.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.tools.baloon.js $
 */

/**
 * Skoll loading screen.
 */
Skoll.tools.Baloon = {
	//
	// Protected properties.
	_container: null,
	_delay: 3000,
	_lastId: 0,
	//
	// Public methods.
	message: function(message, delay) {
		if (typeof delay === "undefined") {
			delay = Skoll.tools.Baloon._delay;
		}

		Skoll.tools.Baloon._initContainer();

		var id = "SkollBaloon_" + Skoll.tools.Baloon._lastId;
		Skoll.tools.Baloon._lastId++;
		Skoll.tools.Baloon._container.append('<div id="' + id + '" class="PopUp" hidden="hidden">' + message + '</div>');
		console.log($("#SkollBaloonContainer"));

		$("#" + id).fadeIn(function() {
			window.setTimeout(function() {
				$("#" + id).fadeOut(function() {
					$(this).remove();
				});
			}, delay);
		});
	},
	//
	// Protected methods.
	_initContainer: function() {
		if (Skoll.tools.Baloon._container === null) {
			$("body").append('<div id="SkollBaloonContainer" class="PopUpContainer"></div>');
			Skoll.tools.Baloon._container = $("#SkollBaloonContainer");
		}
	}
};